const User = require('./User');
const Article = require('./Article');
const Comment = require('./Comment');
//文章与用户一对一
Article.belongsTo(User, { targetKey: 'id', foreignKey: 'userId' });
User.hasOne(Article);
//文章与评论一对多
Article.hasMany(Comment);
Comment.belongsTo(Article, { targetKey: 'id', foreignKey: 'articleId' });
// 用户与评论一对多
Article.hasMany(Comment);
Comment.belongsTo(Article, { targetKey: 'id', foreignKey: 'articleId' });
Comment.findAll(
    {
        include: [ Article ]
    }
).then(res => {
    console.log(res);
}).catch(e => {
    console.log(e);
})
